﻿<div class="row">
    <div class="col-lg-21 col-sm-12 col-xs-12">
        <div class="well with-header flat">
            <div class="header bg-themeprimary">
                <div class="header bg-blue">
                    Share
                </div>
            </div>
            <div class="body" ng-controller="ShareController">
                <!--Begin chart-->
                <div class="row">
                    <div class="col-xs-12 col-md-6">
                        <div class="widget">
                            <div class="widget-header">
                                <span class="widget-caption">Buy</span>
                            </div>
                            <div class="widget-body">
                                <div class="chartcontainer">
                                    <canvas id="buy" height="300" width="450"></canvas>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-md-6">                        
                        <div class="widget">
                            <div class="widget-header">
                                <span class="widget-caption">Sales</span>
                            </div>
                            <div class="widget-body">
                                <div class="chartcontainer">
                                    <canvas id="sales" height="300" width="450"></canvas>
                                </div>
                            </div>
                        </div>                       
                    </div>
                </div>
                <!--End chart-->                          
                <tabset justified="true">
                    <tab heading="Buy">
                        <div class="widget">
                            <div class="widget-header">
                                <span class="widget-caption">Buy</span>
                                <div class="widget-buttons">
                                    <a href="" ng-click="popup('','FormBuyShareModal','BuyShareModalInstanceCtrl','sm')"><i class="fa fa-plus"> Add</i></a>
                                </div>
                            </div>
                            <div class="widget-body">
                                <table class="table table-bordered table-striped table-condensed flip-content">
                                    <thead class="flip-content bordered-palegreen">
                                        <tr>
                                            <th>Name</th>
                                            <th>Quantity</th>
                                            <th>Unit</th>
                                            <th class="numeric">Price</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="data in Buylists" ng-if="Buylists.length != 0">
                                            <td>>{{data.UserName}}</td>
                                            <td class="numeric">{{data.Quantity}}</td>
                                            <td class="numeric">{{data.Unit}}</td>
                                            <td class="numeric">${{data.Quantity*data.Unit}}</td>
                                        </tr>
                                        <tr ng-if="Buylists.length == 0">
                                            <td colspan="4">
                                                No Data
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </tab>
                    <tab heading="Sales">
                        <div class="widget">
                            <div class="widget-header">
                                <span class="widget-caption">Sales</span>
                                <div class="widget-buttons">
                                    <a class="" href="" ng-click="popup('','FormSaleShareModal','SellShareModalInstanceCtrl','sm')"><i class="fa fa-plus"> Add</i></a>
                                </div>
                            </div>
                            <div class="widget-body">
                                <table class="table table-bordered table-striped table-condensed flip-content">
                                    <thead class="flip-content bordered-palegreen">
                                        <tr>
                                            <th>Name</th>
                                            <th>Quantity</th>
                                            <th>Unit</th>
                                            <th class="numeric">Price</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="data in SellLists" ng-show="SellLists.length != 0">
                                            <td>{{data.UserName}}</td>
                                            <td class="numeric">{{data.Quantity}}</td>
                                            <td class="numeric">{{data.Unit|number:2}}</td>
                                            <td class="numeric">{{data.Quantity*data.Unit|number:2}}</td>
                                        </tr>
                                        <tr ng-if="SellLists.length == 0">
                                            <td colspan="4">
                                                No Data
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </tab>
                    <tab heading="Manage">                        
                        <div class="widget">
                            <div class="widget-header">
                                <span class="widget-caption">Manage</span>      
                                <div class="widget-buttons">
                                    <a href="" ng-click="popup('','FormAddShareWalletModal','AddShareWalletModalInstanceCtrl','sm')"><i class="fa fa-plus"> Add</i></a>
                                </div>                                                          
                            </div>
                            <div class="widget-body">
                                <table class="table table-bordered table-striped table-condensed flip-content">
                                    <thead class="flip-content bordered-palegreen">
                                        <tr>
                                            <th>Date</th>
                                            <th>Quantity</th>
                                            <th>Unit</th>
                                            <th class="numeric">Price</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="data in ShareManage" ng-show="ShareManage.length != 0">
                                            <td>{{data.DataCreate}}</td>
                                            <td class="numeric">
                                                <span ng-if="data.Type==0">Buy</span>
                                                <span ng-if="data.Type!=0">Sales</span>
                                            </td>
                                            <td class="numeric">${{data.Unit}}</td>
                                            <td class="numeric">${{data.Price}}</td>
                                        </tr>
                                        <tr ng-if="ShareManage.length == 0">
                                            <td colspan="4">
                                                No Data
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </tab>
                    <tab heading="History">                        
                        <div class="widget">
                            <div class="widget-header">
                                <span class="widget-caption">History</span>
                            </div>
                            <div class="widget-body">
                                <table class="table table-bordered table-striped table-condensed flip-content">
                                    <thead class="flip-content bordered-palegreen">
                                        <tr>
                                            <th>Date</th>
                                            <th>Type</th>
                                            <th>Quantity</th>
                                            <th class="numeric">Price</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="data in WalletHistory" ng-show="WalletHistory.length != 0">
                                            <td>{{data.DateCreate}}</td>
                                            <td class="numeric">
                                                <span ng-if="data.Type==1">Buy</span>
                                                <span ng-if="data.Type!=1">Sales</span>
                                            </td>
                                            <td class="numeric">{{data.Quantity}}</td>
                                            <td class="numeric">{{data.Unit}}</td>
                                        </tr>
                                        <tr ng-if="WalletHistory.length == 0">
                                            <td colspan="4">
                                                No Data
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </tab>
                </tabset>
            
            
                <!--Success Modal Templates-->
                <script type="text/ng-template" id="WarningModal">
                    <div class="modal-header">
                        <i class="glyphicon glyphicon-check"></i>
                    </div>
                    <div class="modal-title">{{title}}</div>
                    <div class="modal-body">
                        {{ messeger }}
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success" ng-click="ok()">OK</button>
                        <button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
                    </div>
                </script>
                <!--End Success Modal Templates-->
                <script type="text/ng-template" id="FormBuyShareModal">
                    <div class="modal-header">
                        <strong>Buy Share</strong>
                    </div>
                    <div class="modal-body">
                        <div class="loginbox">
                            {{messeger}}
                            <form name="simpleForm" method="post" class="bv-form" novalidate="novalidate">                                
                                <div class="form-group">
                                    <label>Amount</label>
                                    <input class="form-control" ng-model="data.Amount" type="text" ng-pattern="/^\d+$/" ng-change="doProcess(data)">
                                </div>                             
                                <div class="form-group">
                                    <label>Chose Wallet</label>
                                    <ui-select ng-model="wallet.selected">
                                        <ui-select-match placeholder="Select or search a wallet in the list...">
                                            {{$select.selected.Name}}
                                        </ui-select-match>
                                        <ui-select-choices repeat="item in WalletList | filter: $select.search">
                                            <span ng-bind="item.Name"></span>
                                        </ui-select-choices>
                                    </ui-select>
                                    {{data.WalletId=wallet.selected.Id;""}}
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success" ng-click="doBuyShare(data)">Buy</button>
                        <button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
                    </div>
                </script>

                <!--End Success Modal Templates-->
                <script type="text/ng-template" id="FormSaleShareModal">
                    <div class="modal-header">
                        <strong>Sales Share</strong>
                    </div>
                    <div class="modal-body">
                        <div class="loginbox">
                            {{messeger}}
                            <form name="simpleForm" method="post" class="bv-form" novalidate="novalidate">
                                <div class="form-group">
                                    <label>Amount</label>
                                    <input class="form-control" ng-model="data.Amount" type="text" ng-pattern="/^\d+$/" ng-change="doProcess(data)">
                                </div>
                                <div class="form-group">
                                    <label>Chose Wallet</label>
                                    <ui-select ng-model="wallet.selected">
                                        <ui-select-match placeholder="Select or search a wallet in the list...">
                                            {{$select.selected.Name}}
                                        </ui-select-match>
                                        <ui-select-choices repeat="item in WalletList | filter: $select.search">
                                            <span ng-bind="item.Name"></span>
                                        </ui-select-choices>
                                    </ui-select>
                                    {{data.WalletId=wallet.selected.Id;""}}
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success" ng-click="doSellShare(data)">Buy</button>
                        <button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
                    </div>
                </script>
                
                  <!--Add Share Wallet-->
                <script type="text/ng-template" id="FormAddShareWalletModal">
                    <div class="modal-header">
                        <strong>Buy Share</strong>
                    </div>
                    <div class="modal-body">
                        <div class="loginbox">
                            
                            {{messeger}}

                            <form name="simpleForm" method="post" class="bv-form" novalidate="novalidate">
                                <div class="form-group">
                                    <label>Chose Wallet</label>
                                    <ui-select ng-model="type.selected">
                                        <ui-select-match placeholder="Select or search a wallet in the list...">
                                            {{$select.selected.Name}}
                                        </ui-select-match>
                                        <ui-select-choices repeat="item in ShareTypes | filter: $select.search">
                                            <span ng-bind="item.Name"></span>
                                        </ui-select-choices>
                                    </ui-select>
                                    {{Share.Type=type.selected.Id;""}}
                                </div>
                                <div class="form-group" ng-if="Share.Type==0">
                                    <label>Chose Wallet</label>
                                    <ui-select ng-model="wallet.selected">
                                        <ui-select-match placeholder="Select or search a wallet in the list...">
                                            {{$select.selected.Name}}
                                        </ui-select-match>
                                        <ui-select-choices repeat="item in WalletList | filter: $select.search">
                                            <span ng-bind="item.Name"></span>
                                        </ui-select-choices>
                                    </ui-select>
                                    {{Share.WalletId=wallet.selected.Id;""}}
                                </div>
                                <div class="form-group">
                                    <label>Quantity</label>
                                    <input class="form-control" ng-model="Share.Quantity" type="text">
                                </div>

                                <div class="form-group">
                                    <label>Unit Price</label>
                                    <input class="form-control" ng-model="Share.UnitPrice" type="text" ng-pattern="/^\d+$/">
                                </div>                                
                                <div class="form-group">
                                    <label>Total</label>
                                    <input class="form-control"  type="text" readonly value="{{ Share.UnitPrice*Share.Quantity }}">
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success" ng-click="doAddShare(Share)">Summit</button>
                        <button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
                    </div>
                </script>
            </div>
        </div>
    </div>
</div>